//
//  UINavigationController+LGLeaksTest.m
//  CustomLeakTest
//
//  Created by yunyi on 2020/4/25.
//  Copyright © 2020 yunyi. All rights reserved.
//

#import "UINavigationController+LGLeaksTest.h"
#import "NSObject+LGSwizzing.h"
#import <objc/runtime.h>


@implementation UINavigationController (LGLeaksTest)

+ (void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        //交换方法--》 pop方法
        [self swizzleSEL:@selector(popViewControllerAnimated:) withSEL:@selector(lg_popViewControllerAnimated:)];
    });
}

- (UIViewController *)lg_popViewControllerAnimated:(BOOL)animated {
    UIViewController *popVC = [self lg_popViewControllerAnimated:animated];//pop的出去的VC
    
    //设置popvc出去的属性状态
    extern const char * LGVCFLAT;//声明
    objc_setAssociatedObject(popVC, LGVCFLAT, @(YES), OBJC_ASSOCIATION_ASSIGN);
    
    return popVC;
}
@end
